<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../../../../style.css" type="text/css" media="screen">
<link rel="stylesheet" href="../../../../print.css" type="text/css" media="print">
<meta content="IMediator,org.puremvc.as3.interfaces.IMediator,getMediatorName,getViewComponent,handleNotification,listNotificationInterests,onRegister,onRemove,setViewComponent" name="keywords">
<title>org.puremvc.as3.interfaces.IMediator</title>
</head>
<body>
<script type="text/javascript" language="javascript" src="../../../../asdoc.js"></script><script type="text/javascript" language="javascript" src="../../../../cookies.js"></script><script type="text/javascript" language="javascript">
<!--
				asdocTitle = 'IMediator - API Documentation';
				var baseRef = '../../../../';
				window.onload = configPage;
			--></script>
<table style="display:none" id="titleTable" cellspacing="0" cellpadding="0" class="titleTable">
<tr>
<td align="left" class="titleTableTitle">PureMVC AS3 Framework - [Standard Version]</td><td align="right" class="titleTableTopNav"><a onclick="loadClassListFrame('../../../../all-classes.html')" href="../../../../package-summary.html">All&nbsp;Packages</a>&nbsp;|&nbsp;<a onclick="loadClassListFrame('../../../../all-classes.html')" href="../../../../class-summary.html">All&nbsp;Classes</a>&nbsp;|&nbsp;<a onclick="loadClassListFrame('../../../../index-list.html')" href="../../../../all-index-A.html">Index</a>&nbsp;|&nbsp;<a href="../../../../index.html?org/puremvc/as3/interfaces/IMediator.html&amp;org/puremvc/as3/interfaces/class-list.html" id="framesLink1">Frames</a><a onclick="parent.location=document.location" href="" style="display:none" id="noFramesLink1">No&nbsp;Frames</a></td><td rowspan="3" align="right" class="titleTableLogo"><img alt="Adobe Logo" title="Adobe Logo" class="logoImage" src="../../../../images/logo.jpg"></td>
</tr>
<tr class="titleTableRow2">
<td align="left" id="subTitle" class="titleTableSubTitle">Interface&nbsp;IMediator</td><td align="right" id="subNav" class="titleTableSubNav"><a href="#methodSummary">Methods</a></td>
</tr>
<tr class="titleTableRow3">
<td colspan="2">&nbsp;</td>
</tr>
</table>
<script type="text/javascript" language="javascript">
<!--
if (!isEclipse() || window.name != ECLIPSE_FRAME_NAME) {titleBar_setSubTitle("Interface IMediator"); titleBar_setSubNav(false,false,false,false,false,false,true,false,false,false,false,false,false,false);}
--></script>
<div class="MainContent">
<table cellspacing="0" cellpadding="0" class="classHeaderTable">
<tr>
<td class="classHeaderTableLabel">Package</td><td><a onclick="javascript:loadClassListFrame('class-list.html')" href="package-detail.html">org.puremvc.as3.interfaces</a></td>
</tr>
<tr>
<td class="classHeaderTableLabel">Interface</td><td class="classSignature">public interface IMediator</td>
</tr>
<tr>
<td class="classHeaderTableLabel">Implementors</td><td><a href="../patterns/mediator/Mediator.html">Mediator</a></td>
</tr>
</table>
<p></p>
  The interface definition for a PureMVC Mediator.
    <P>
  In PureMVC, <code>IMediator</code> implementors assume these responsibilities:</P>
  <UL>
  <LI>Implement a common method which returns a list of all <code>INotification</code>s 
  the <code>IMediator</code> has interest in.</LI>
  <LI>Implement a notification callback method.</LI>
  <LI>Implement methods that are called when the IMediator is registered or removed from the View.</LI>
  </UL>
  <P>
  Additionally, <code>IMediator</code>s typically:
  <UL>
  <LI>Act as an intermediary between one or more view components such as text boxes or 
  list controls, maintaining references and coordinating their behavior.</LI>
  <LI>In Flash-based apps, this is often the place where event listeners are
  added to view components, and their handlers implemented.</LI>
  <LI>Respond to and generate <code>INotifications</code>, interacting with of 
  the rest of the PureMVC app.
  </UL></P>
  <P>
  When an <code>IMediator</code> is registered with the <code>IView</code>, 
  the <code>IView</code> will call the <code>IMediator</code>'s 
  <code>listNotificationInterests</code> method. The <code>IMediator</code> will 
  return an <code>Array</code> of <code>INotification</code> names which 
  it wishes to be notified about.</P>
  
  <P>
  The <code>IView</code> will then create an <code>Observer</code> object 
  encapsulating that <code>IMediator</code>'s (<code>handleNotification</code>) method
  and register it as an Observer for each <code>INotification</code> name returned by 
  <code>listNotificationInterests</code>.</P>
  
  <P>
  A concrete IMediator implementor usually looks something like this:</P>
  
  <div class='listing'><pre>
  import org.puremvc.as3.patterns.mediator.*;
  import org.puremvc.as3.patterns.observer.*;
  import org.puremvc.as3.core.view.*;
  
  import com.me.myapp.model.*;
  import com.me.myapp.view.*;
  import com.me.myapp.controller.*;
    
  import mx.controls.ComboBox;
  import mx.events.ListEvent;
  
  public class MyMediator extends Mediator implements IMediator {
  
    public function MyComboMediator( viewComponent:Object ) {
     super( viewComponent );
     combo.addEventListener( Event.CHANGE, onChange );
    }
    
    override public function listNotificationInterests():Array {
      return [ MyFacade.SET_SELECTION, 
         MyFacade.SET_DATAPROVIDER ];
    }
  
    override public function handleNotification( notification:INotification ):void {
      switch ( notification.getName() ) {
       case MyFacade.SET_SELECTION:
        setSelection(notification);
        break;
       case MyFacade.SET_DATAPROVIDER:
        setDataProvider(notification);
        break;
      }
    }
  
    // Set the data provider of the combo box
    protected function setDataProvider( notification:INotification ):void {
     combo.dataProvider = notification.getBody() as Array;
    }
  
    // Invoked when the combo box dispatches a change event, we send a
       // notification with the
    protected function onChange(event:ListEvent):void {
     sendNotification( MyFacade.MYCOMBO_CHANGED, this );
    }
  
    // A private getter for accessing the view object by class
       protected function get combo():ComboBox  {
          return view as ComboBox;
       }
  
  }
  </pre></div>
  
  <p></p>
<p>
<span class="classHeaderTableLabel">See also</span>
</p>
<div class="seeAlso">
<a href="../interfaces/INotification.html" target="">INotification</a>
</div>
<br>
<hr>
</div>
<a name="methodSummary"></a>
<div class="summarySection">
<div class="summaryTableTitle">Public Methods</div>
<table id="summaryTableMethod" class="summaryTable " cellpadding="3" cellspacing="0">
<tr>
<th>&nbsp;</th><th colspan="2">Method</th><th class="summaryTableOwnerCol">Defined&nbsp;by</th>
</tr>
<tr class="">
<td class="summaryTablePaddingCol">&nbsp;</td><td class="summaryTableInheritanceCol">&nbsp;</td><td class="summaryTableSignatureCol">
<div class="summarySignature">
<a class="signatureLink" href="#getMediatorName()">getMediatorName</a>():String</div>
<div class="summaryTableDescription">
   Get the <code>IMediator</code> instance name
   
   </div>
</td><td class="summaryTableOwnerCol">IMediator</td>
</tr>
<tr class="">
<td class="summaryTablePaddingCol">&nbsp;</td><td class="summaryTableInheritanceCol">&nbsp;</td><td class="summaryTableSignatureCol">
<div class="summarySignature">
<a class="signatureLink" href="#getViewComponent()">getViewComponent</a>():Object</div>
<div class="summaryTableDescription">
   Get the <code>IMediator</code>'s view component.</div>
</td><td class="summaryTableOwnerCol">IMediator</td>
</tr>
<tr class="">
<td class="summaryTablePaddingCol">&nbsp;</td><td class="summaryTableInheritanceCol">&nbsp;</td><td class="summaryTableSignatureCol">
<div class="summarySignature">
<a class="signatureLink" href="#handleNotification()">handleNotification</a>(notification:<a href="INotification.html">INotification</a>):void</div>
<div class="summaryTableDescription">
   Handle an <code>INotification</code>.</div>
</td><td class="summaryTableOwnerCol">IMediator</td>
</tr>
<tr class="">
<td class="summaryTablePaddingCol">&nbsp;</td><td class="summaryTableInheritanceCol">&nbsp;</td><td class="summaryTableSignatureCol">
<div class="summarySignature">
<a class="signatureLink" href="#listNotificationInterests()">listNotificationInterests</a>():Array</div>
<div class="summaryTableDescription">
   List <code>INotification</code> interests.</div>
</td><td class="summaryTableOwnerCol">IMediator</td>
</tr>
<tr class="">
<td class="summaryTablePaddingCol">&nbsp;</td><td class="summaryTableInheritanceCol">&nbsp;</td><td class="summaryTableSignatureCol">
<div class="summarySignature">
<a class="signatureLink" href="#onRegister()">onRegister</a>():void</div>
<div class="summaryTableDescription">
   Called by the View when the Mediator is registered
   </div>
</td><td class="summaryTableOwnerCol">IMediator</td>
</tr>
<tr class="">
<td class="summaryTablePaddingCol">&nbsp;</td><td class="summaryTableInheritanceCol">&nbsp;</td><td class="summaryTableSignatureCol">
<div class="summarySignature">
<a class="signatureLink" href="#onRemove()">onRemove</a>():void</div>
<div class="summaryTableDescription">
   Called by the View when the Mediator is removed
   </div>
</td><td class="summaryTableOwnerCol">IMediator</td>
</tr>
<tr class="">
<td class="summaryTablePaddingCol">&nbsp;</td><td class="summaryTableInheritanceCol">&nbsp;</td><td class="summaryTableSignatureCol">
<div class="summarySignature">
<a class="signatureLink" href="#setViewComponent()">setViewComponent</a>(viewComponent:Object):void</div>
<div class="summaryTableDescription">
   Set the <code>IMediator</code>'s view component.</div>
</td><td class="summaryTableOwnerCol">IMediator</td>
</tr>
</table>
</div>
<script type="text/javascript" language="javascript">
<!--
showHideInherited();
--></script>
<div class="MainContent">
<a name="methodDetail"></a>
<div class="detailSectionHeader">Method detail</div>
<a name="getMediatorName()"></a>
<table cellspacing="0" cellpadding="0" class="detailHeader">
<tr>
<td class="detailHeaderName">getMediatorName</td><td class="detailHeaderParens">()</td><td class="detailHeaderType">method</td>
</tr>
</table>
<div class="detailBody">
<code>public function getMediatorName():String</code><p>
   Get the <code>IMediator</code> instance name
   
   </p><p></p>
<span class="label">Returns</span>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="20"></td><td><code>String</code> &mdash; the <code>IMediator</code> instance name
   </td>
</tr>
</table>
</div>
<a name="getViewComponent()"></a>
<table cellspacing="0" cellpadding="0" class="detailHeader">
<tr>
<td class="detailHeaderName">getViewComponent</td><td class="detailHeaderParens">()</td><td class="detailHeaderType">method</td><td class="detailHeaderRule">&nbsp;</td>
</tr>
</table>
<div class="detailBody">
<code>public function getViewComponent():Object</code><p>
   Get the <code>IMediator</code>'s view component.
   
   </p><p></p>
<span class="label">Returns</span>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="20"></td><td><code>Object</code> &mdash; Object the view component
   </td>
</tr>
</table>
</div>
<a name="handleNotification()"></a>
<table cellspacing="0" cellpadding="0" class="detailHeader">
<tr>
<td class="detailHeaderName">handleNotification</td><td class="detailHeaderParens">()</td><td class="detailHeaderType">method</td><td class="detailHeaderRule">&nbsp;</td>
</tr>
</table>
<div class="detailBody">
<code>public function handleNotification(notification:<a href="INotification.html">INotification</a>):void</code><p>
   Handle an <code>INotification</code>.
   
   </p><span class="label">Parameters</span>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="20px"></td><td><code><span class="label">notification</span>:<a href="INotification.html">INotification</a></code> &mdash; the <code>INotification</code> to be handled
   </td>
</tr>
</table>
</div>
<a name="listNotificationInterests()"></a>
<table cellspacing="0" cellpadding="0" class="detailHeader">
<tr>
<td class="detailHeaderName">listNotificationInterests</td><td class="detailHeaderParens">()</td><td class="detailHeaderType">method</td><td class="detailHeaderRule">&nbsp;</td>
</tr>
</table>
<div class="detailBody">
<code>public function listNotificationInterests():Array</code><p>
   List <code>INotification</code> interests.
   
   </p><p></p>
<span class="label">Returns</span>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="20"></td><td><code>Array</code> &mdash; an <code>Array</code> of the <code>INotification</code> names this <code>IMediator</code> has an interest in.
   </td>
</tr>
</table>
</div>
<a name="onRegister()"></a>
<table cellspacing="0" cellpadding="0" class="detailHeader">
<tr>
<td class="detailHeaderName">onRegister</td><td class="detailHeaderParens">()</td><td class="detailHeaderType">method</td><td class="detailHeaderRule">&nbsp;</td>
</tr>
</table>
<div class="detailBody">
<code>public function onRegister():void</code><p>
   Called by the View when the Mediator is registered
   </p></div>
<a name="onRemove()"></a>
<table cellspacing="0" cellpadding="0" class="detailHeader">
<tr>
<td class="detailHeaderName">onRemove</td><td class="detailHeaderParens">()</td><td class="detailHeaderType">method</td><td class="detailHeaderRule">&nbsp;</td>
</tr>
</table>
<div class="detailBody">
<code>public function onRemove():void</code><p>
   Called by the View when the Mediator is removed
   </p></div>
<a name="setViewComponent()"></a>
<table cellspacing="0" cellpadding="0" class="detailHeader">
<tr>
<td class="detailHeaderName">setViewComponent</td><td class="detailHeaderParens">()</td><td class="detailHeaderType">method</td><td class="detailHeaderRule">&nbsp;</td>
</tr>
</table>
<div class="detailBody">
<code>public function setViewComponent(viewComponent:Object):void</code><p>
   Set the <code>IMediator</code>'s view component.
   
   </p><span class="label">Parameters</span>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="20px"></td><td><code><span class="label">viewComponent</span>:Object</code> &mdash; the view component
   </td>
</tr>
</table>
</div>
<br>
<br>
<hr>
<br>
<p></p>
<center class="copyright">
<footer> 
</footer>
</center>
</div>
</body>
</html>
<!-- -->
